﻿using IntelligentAgriculture.Contracts.Dto.Input;
using IntelligentAgriculture.Contracts.Dto.Output;
using IntelligentAgriculture.Contracts.Interface;
using IntelligentAgriculture.Domain.Entity;
using IntelligentAgriculture.Services;
using IntelligentAgriculture.WebAPI.Application.Command.StartCommand;
using MediatR;
using Microsoft.EntityFrameworkCore;
using SqlSugar;

namespace IntelligentAgriculture.WebAPI.Application.CommandHandler.StartCommandHandler
{
    /// <summary>
    /// 期初显示查询CommandHandler
    /// </summary>
    public class StartSelectCommandHandler : IRequestHandler<StartSelectCommand, Results<PageOutput<StartOutput>>>
    {
        private readonly IStartService _startService;
        public StartSelectCommandHandler(IStartService startService)
        {
            _startService = startService;
        }

        public async Task<Results<PageOutput<StartOutput>>> Handle(StartSelectCommand request, CancellationToken cancellationToken)
        {

            var list = await _startService.GetStartList(request.EarTag);

            return Results<PageOutput<StartOutput>>.DataResult(list);
        }
    }
}
